<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="/css/bootstrap-select.min.css">
    <script src="/js/libs/jquery-2.1.1.min.js"></script>
    <script src="/js/bootstrap/bootstrap.min.js"></script>
    <script src="/js/bootstrap/bootstrap-select.min.js"></script>
    <script src="/js/jq.js"></script>
    <script src="/js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/layui/layui.js"></script>
    <script src="/js/dict.js"></script>
    <script src="/js/libs/jquery.ztree.all-3.5.min.js"></script>
    <script src="/js/my/ztree-menu.js"></script>
    <script src="/js/my/permission.js"></script>
    <script src="/js/plugin/datatables/jquery.dataTables.min.js"></script>
    <script src="/js/plugin/datatables/dataTables.bootstrap.min.js"></script>

</head>
<body>
<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <div>
            <header style="height: 100%">
                <div align="left">
                    <table style="width: 100%">
                        <tr>
                            <td>
                                <form id="form" class="form-inline" method="post" action="/handOver/export" enctype="multipart/form-data">
                                <!--<form class="form-inline" action="" onsubmit="return false" id="form">-->
                                    <div class="form-group">
                                        原归属人：
                                        <input class='form-control' type='hidden' name='handlerId' id='handlerId'>
                                        <input class='form-control input-small' placeholder='原归属人' type='text'
                                               name='handlerName' id='handlerName'
                                               readonly>
                                        <a href="#" class="layui-btn layui-btn-sm"
                                                onclick="showTableAndFlushFields('user', 'user', '用户', true, false, 'handlerId:id', 'handlerName:nickname');return false;">
                                            <i class="layui-icon">&#xe615;</i>
                                        </a>
                                        原归属部门：
                                        <input class='form-control' type='hidden' name='deployComeId' id='deployComeId' >
                                        <input class='form-control input-small' placeholder='原归属部门' type='text' name='deployComeName' id='deployComeName' readonly>
                                        <a href="#" class="layui-btn layui-btn-sm"
                                                onclick="showSpecialTree('deployComeId', 'deployComeName', 'dept', '部门', 'root', 'select','fasDeptTree');return false;">
                                            <i class="layui-icon">&#xe615;</i>
                                        </a>
                                        创建时间：
                                        <input type="text" class="form-control input-small" placeholder="开始..." id="beginTime" name="beginTime" >
                                        -
                                        <input type="text" class="form-control input-small" placeholder="结束..." id="endTime" name="endTime">
                                    </div>
                                    <br><br>
                                    <div class="form-group">
                                        接收人：
                                        <input class='form-control' type='hidden' name='deployForpeoId' id='deployForpeoId'>
                                        <input class='form-control input-small span1' placeholder='接收人' type='text'
                                               name='deployForpeoName' id='deployForpeoName'
                                               readonly>
                                        <a href="#" class="layui-btn layui-btn-sm"
                                                onclick="showTableAndFlushFields('user', 'user', '用户', true, false, 'deployForpeoId:id', 'deployForpeoName:nickname');return false;">
                                            <i class="layui-icon">&#xe615;</i>
                                        </a>
                                        接收部门：
                                        <input class='form-control' type='hidden' name='deployForId' id='deployForId' >
                                        <input class='form-control input-small' placeholder='接收部门' type='text' name='deployForName' id='deployForName' readonly>
                                        <a href="#" class="layui-btn layui-btn-sm"
                                                onclick="showSpecialTree('deployForId', 'deployForName', 'dept', '部门', 'root', 'select','fasDeptTree');return false;">
                                            <i class="layui-icon">&#xe615;</i>
                                        </a>
                                        操作类型：
                                        <select class="form-control input-sm col-md-1 selectpicker show-tick" name="handleType" id="handleType"
                                                title="操作类型" data-live-search="true">
                                        </select>
                                        商品名称：<input id="goodsName" name="goodsName" type="text" class="form-control" placeholder="商品名称">
                                    </div>
                                </form>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <button id="searchBt" class="layui-btn layui-btn-sm search"><i class="layui-icon">&#xe615;</i>搜索</button>
                            </td>
                            <td align="right">
                                <iframe id="export" style="display:none"></iframe>
                                <button class='layui-btn layui-btn-sm' permission="fas:handOver:export" onclick="exportData()">
                                    <i class='layui-icon'>&#xe601;</i> 导出
                                </button>
                            </td>
                        </tr>
                    </table>
                </div>
            </header>

            <div>
                <div class="widget-body no-padding">
                    <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                        <thead>
                            <tr>
                            </tr>
                            <tr>
                                <th>id</th>
                                <th>原归属部门名</th>
                                <th>原归属人名</th>
                                <th>接收部门名</th>
                                <th>接收人名</th>
                                <th>操作类型</th>
                                <th>商品编码</th>
                                <th>商品名称</th>
                                <th>商品规格</th>
                                <th>数量</th>
                                <th>单位</th>
                                <th>单价</th>
                                <th>总价</th>
                                <th>创建时间</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
layui.use(['layer','laydate'], function(){
    var layer = layui.layer;
    var laydate = layui.laydate;
    laydate.render({
        elem: '#beginTime'
    });
    laydate.render({
        elem: '#endTime'
    });
});

var pers = checkPermission();

showDictSelect('handleType', 'sm_handleType', '--请选择--', '');

var example;
function init(){

	example = 
    	$('#dt-table').DataTable({
        	"searching": false,
        	"processing": false,
        	"serverSide" : true,
        	"language": {
                "url": "/js/plugin/datatables/Chinese.lang"
            },
        	"ajax": {
        		"url" : "/handOver/list",
        		"type":"get",
        		"data":function(d){
                    d.handlerId = $("#handlerId").val();
                    d.beginTime = $("#beginTime").val();
                    d.endTime = $("#endTime").val();
                    d.handleType = $("#handleType").val();
                    d.deployComeId = $("#deployComeId").val();
                    d.deployForpeoId = $("#deployForpeoId").val();
                    d.deployForId = $("#deployForId").val();
                    d.type = 'diaobo';
                    d.goodsName = $("#goodsName").val();
    			}
        	},
        	"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",	
            "columns": [
                {"data" : "id", "defaultContent" : ""},
                {"data" : "deployComeName", "defaultContent" : ""},
                {"data" : "handlerName", "defaultContent" : ""},
                {"data" : "deployForName", "defaultContent" : ""},
                {"data" : "deployForpeoName", "defaultContent" : ""},
                {
                    "data": "handleType",
                    "defaultContent": "",
                    "render": function (data, type, row) {
                        return getDict('sm_handleType')[data];
                    }
                },
                {"data" : "goodsCode", "defaultContent" : ""},
                {"data" : "goodsName", "defaultContent" : ""},
                {"data" : "detailSpec", "defaultContent" : ""},
                {"data" : "detailNum", "defaultContent" : ""},
                {"data" : "detailUnit", "defaultContent" : ""},
                {"data" : "unitPrice", "defaultContent" : ""},
                {"data" : "totalPrice", "defaultContent" : ""},
                {"data" : "createTime", "defaultContent" : ""},
            ],
           "order": [[ 11, "asc" ]]
        } );
}



function del(id){
	layer.confirm('确定要删除吗？', {
        btn : [ '确定', '取消' ]
    }, function() {
    	$.ajax({
            type : 'delete',
            url : '/handOver/'+id,
            success : function(data) {
                example.ajax.reload();
                layer.msg("删除成功");
            }
        });
        
        layer.close(1);
    });
}

$("#searchBt").click(function(){
	example.ajax.reload();
});

init();


// 导出
function exportData() {
    layer.confirm('请选择要导出的方式', {
        btn: ['导出数据','导出空白模板'] //按钮
    }, function(index){
        $('#form').attr('action', '/handOver/export/1').submit();
        layer.close(index);
    }, function(){
        $('#form').attr('action', '/handOver/export/0').submit();
    });
}
</script>
